import QtQuick 2.2
import QtQuick.Controls 1.1

ApplicationWindow {
    visible: true
    width: 832
    height: 496
    title: qsTr("Exercise - 6")

    property color backColor: "black"

    Rectangle{
        id: rootRect
        anchors.fill: parent
        Title{
            id: title
            width: rootRect.width; height:rootRect.height/6
            anchors.top: rootRect.top
            anchors.left: rootRect.left
            onReturnBtnClicked: {
                Qt.quit();
            }
        }
        Rectangle{
            id: space
            width: parent.width
            height: 2
            anchors.top: title.bottom
            anchors.horizontalCenter: parent.horizontalCenter
            color: "lightgrey"
        }

        Rectangle{
            id: middleRootRect
            width: rootRect.width
            height: rootRect.height/12*7
            anchors.top: space.bottom
            anchors.horizontalCenter: rootRect.horizontalCenter

            Rectangle{
                id: imageRect
                color: backColor
                width: parent.width*0.4
                height: parent.height
                anchors.left: parent.left
                anchors.verticalCenter: parent.verticalCenter
                ImageView{
                    id: imageView
                    fileName: "images/image/K0.png"
                    anchors.leftMargin: parent.width*0.05
                    anchors.rightMargin: parent.width*0.05
                    anchors.bottomMargin: parent.height*0.1
                    anchors.topMargin: parent.height*0.1
                }
            }

            Rectangle{
                id: volumns
                anchors.left: imageRect.right
                anchors.verticalCenter: imageRect.verticalCenter
                width:  parent.width*0.6
                height: parent.height
                color: "black"
                Column{
                    anchors.horizontalCenter: parent.horizontalCenter
                    anchors.verticalCenter: parent.verticalCenter
                    width: parent.width; height: parent.height/2
                    spacing: 2
                    Volumn{
                        title: "Brightness"
                        size: 11
                        width: parent.width*0.8
                        height: parent.height/2
                        anchors.horizontalCenter: parent.horizontalCenter
                        onVolumnChanged: {
                            var images = new Array("K0.png", "K1.png",
                                                   "K2.png", "K3.png",
                                                   "K4.png", "K5.png",
                                                   "K6.png", "K7.png",
                                                   "K8.png", "K9.png", "K10.png");
                            imageView.fileName = "images/image/"+images[(volumn-1)%images.length];
                        }
                    }
                    Volumn{
                        title: "Contrast"
                        size: 11
                        width: parent.width*0.8
                        height: parent.height/2
                        anchors.horizontalCenter: parent.horizontalCenter
                    }
                }
            }
        }
        Bottom{
            width: rootRect.width
            height: rootRect.height-title.height
                    -space.height-middleRootRect.height
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            onOkBtnClicked: {
                Qt.quit();
            }
        }
    }
}
